#include "uhm/common.hxx"
#include "uhm/util.hxx"

#include "uhm/discrete/base/tree.hxx"

using namespace uhm;


typedef Tree_<Int_,3> Tree;

int main (int argc, char **argv) {

  {
    Tree::Tnd_ nd(1, 0);
    std::cout << nd << std::endl;
    
    Tree::Tnd_ c1(2), c2(3), c3(4);
    nd.add_child(&c1);
    nd.add_child(&c2);
    nd.add_child(&c3);
    
    nd.set_gen();

    std::cout << nd << std::endl;
  }

  {
    Tree tree;
    Tree::Tnd_ *n, *c;
    tree.set_size(10);
    tree.reserve();

    n = tree.add_node(0);
    tree.set_root(n);

    c = tree.add_node(1); n->add_child(c); c->set_parent(n);

    c = tree.add_node(2); n->add_child(c); c->set_parent(n);
    c = tree.add_node(3); n->add_child(c); c->set_parent(n);
    
    n = n->get_child(1);
    c = tree.add_node(4); n->add_child(c); c->set_parent(n);
    c = tree.add_node(5); n->add_child(c); c->set_parent(n);

    n = n->get_child(0);
    c = tree.add_node(6); n->add_child(c); c->set_parent(n);
    c = tree.add_node(7); n->add_child(c); c->set_parent(n);

    tree.set_gen();

    std::cout << tree << std::endl;
  }

  return true;
}


